import * as git from 'isomorphic-git'
import fs from 'fs'
import http from 'isomorphic-git/http/node'
export const initGit = async (rootPath: string, origin: string) => {
  await git.init({ fs, dir: rootPath })
  await git.add({ fs, dir: rootPath, filepath: '.' })
  const author = {
    name: 'test',
    email: 'your-email@example.com'
  }
  await git.commit({ fs, dir: rootPath, author, message: 'Initial commit' })
  await git.branch({ fs, dir: rootPath, ref: 'HEAD' })
  await git.addRemote({ fs, dir: rootPath, remote: 'origin', url: origin })
  await git.push({ fs, http, dir: rootPath, remote: 'origin', ref: 'HEAD' })
}
